package com.fangcun.service.admin.Impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fangcun.bean.admin.log.request.LogRequsetAllSeachRequest;
import com.fangcun.bean.sys.PageBean;
import com.fangcun.common.canstant.ErrCode;
import com.fangcun.common.exception.ProException;
import com.fangcun.common.exception.ProValiDataException;
import com.fangcun.entity.LogsRequestAll;
import com.fangcun.mapper.LogsRequestAllMapper;
import com.fangcun.service.admin.LogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * @作者： 陳曉鬆 @时间： 2020年6月5日 - 上午10:13:43 @description：->
 */
@Service("logService")
public class LogServiceImpl implements LogService {

	@Autowired
	private LogsRequestAllMapper logsRequestAllMapper;

	@Override
	public PageInfo<LogsRequestAll> logsRequestAllList(PageBean<LogRequsetAllSeachRequest> request) throws ProException {
		PageHelper.startPage(request.getPageNum(), request.getPageSize());
		List<LogsRequestAll> list = logsRequestAllMapper.list(request.getParam());
		if (list == null || list.size() == 0) {
			throw new ProValiDataException(ErrCode.NO_DATA.getReturnCode(), ErrCode.NO_DATA.getReturnMsg());
		}
		return new PageInfo<>(list);
	}

	@Override
	public LogsRequestAll logsRequestAllDetail(Long id) throws ProException {
		return logsRequestAllMapper.selectByPrimaryKey(id);
	}

}
